<template>
  <div>
    <el-form ref="form" :model="form" :rules="ruleForm" label-width="80px">
      <el-form-item label="文章名字">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="文章别名">
        <el-input v-model="form.alias"></el-input>
      </el-form-item>
      <el-form-item >
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      form:{
        name:'',
        alias:'',
      },
      token:'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NCwidXNlcm5hbWUiOiJhZG1pbjEyMyIsInBhc3N3b3JkIjoiIiwibmlja25hbWUiOiLlsI_lvIDlp4vlvIDlp4siLCJlbWFpbCI6IjE1NUBxcS5jb20iLCJ1c2VyX3BpYyI6IiIsImlhdCI6MTY4ODcwMDYwNCwiZXhwIjoxNjg4NzM2NjA0fQ.TRAGKuVKdAtfuBJsJR7vHdlxmpZgwdQ7jCSY-MY1MGc',
      ruleForm: {
        name: [{required: true, message: '请输入文章名字', trigger: 'blur'},],
        alias: [{required: true, message: '请输入文章别名', trigger: 'blur'},],
      }
    }
  },
  created() {
    let a = new Promise((resolve,reject) => {
      resolve(123)
    })
    a.then(res=>{
      console.log(res)
    })
  },
  methods: {
    onSubmit(){
      axios.post('http://127.0.0.1:3007/my/article/addcates',{
        data:{
          ...this.form
        },
        headers: {'Authorization': this.token}
      }).then(res=>{
        console.log(res)
        //this.tableList = res.data.data
      }).catch(err=>{
        this.$message.error(err.message)
      })
    },
  }
}
</script>

<style scoped>

</style>
